package com.rabincorp.tactile.entity;

import java.io.Serializable;
import java.util.Date;

public class FeedItem implements Serializable {

    private static final long serialVersionUID = -3746303804989162635L;
    private String title;
    private String link;
    private String description;
    private String guid;
    private String author;
    private Date pubDate;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getLink() {
        return link;
    }

    public void setLink(String link) {
        this.link = link;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getGuid() {
        return guid;
    }

    public void setGuid(String guid) {
        this.guid = guid;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public Date getPubDate() {
        return pubDate;
    }

    public void setPubDate(Date pubDate) {
        this.pubDate = pubDate;
    }

    public String getSummary() {
        String createdSummary = "";
        if (getDescription() != null && !getDescription().isEmpty()) {
            createdSummary = getDescription();
            int endIndex = createdSummary.indexOf(" ", 150);
            if (endIndex != -1) {
                createdSummary = createdSummary.substring(0, endIndex) + "...";
            } else {
                createdSummary = createdSummary.substring(0, 150) + "...";
            }

            createdSummary = createdSummary.replaceAll("\\[p\\]", "").replaceAll("\\[/p\\]", "");

        }
        return createdSummary;
    }
}
